/**
 * Created by zyx on 2015/9/26.
 */

window.onload = function () {

    document.getElementsByTagName('form')[0].onsubmit = function () {
        var doc = document;
        var necList = doc.querySelectorAll('.nec');
        var error = false;
        for(var j = 0; j < necList.length; j ++) {
            var nec = necList[j];
            if(nec.value.length == 0) {
                nec.className += ' error';
                nec.placeholder = '此项必填';
                error = true;
            }
        }

        if(error) {
            return false;
        }
    };
};